<?php
$venderIdField = 'media_venderId_vender_info';
$venderNameField = 'media_name_vender_info';
$venderDescriptionField = 'media_description_vender_info';
$venderAddressField = 'media_venderAddress_vender_info';
$venderPhoneField = 'media_venderPhone_vender_info';
$venderMobileField = 'media_venderMobile_vender_info';
$venderEmailField = 'media_venderEmail_vender_info';
$venderRegionField = 'media_venderRegion_vender_info';
$model->addField($venderNameField);
$model->addField($venderDescriptionField);
$model->addField($venderIdField);
$model->addField($venderAddressField);
$model->addField($venderPhoneField);
$model->addField($venderMobileField);
$model->addField($venderEmailField);
$model->addField($venderRegionField);

$venderTable = new BPSheet('vender');
if ($configId > 0 && $eventId > 0) {
    //$eventTable = new BPEvent();
    //$event = $eventTable->getListById($eventId);
    $configTable = new BPSheet('orderConfig');
    //only one vender for one event
    $config = $configTable->getListById($configId);
    if ($config instanceof BTreeList) {
        $venderItem = $config->getItem('venderId');
        if ($venderItem instanceof BTreeItem) {
            $venderId = $venderItem->getValue();
            $vender = $venderTable->getListById($venderId);

            $nameItem = $vender->getItem('name');
            if ($nameItem instanceof BTreeItem) {
                $venderName = $nameItem->getValue();
                $model->$venderNameField = $venderName;
            }

            $descItem = $vender->getItem('description');
            if ($descItem instanceof BTreeItem) {
                $venderDescription = $descItem->getValue();
                $model->$venderDescriptionField = $venderDescription;
            }

            $venderIdItem = $vender->getItem('venderId');
            if ($venderIdItem instanceof BTreeItem) {
                $venderId = $venderIdItem->getValue();
                $model->$venderIdField = $venderId;
            }

            $addressItem = $vender->getItem('address');
            if ($addressItem instanceof BTreeItem) {
                $venderAddress = $addressItem->getValue();
                $model->$venderAddressField = $venderAddress;
            }

            $phoneItem = $vender->getItem('phone');
            if ($phoneItem instanceof BTreeItem) {
                $venderPhone = $phoneItem->getValue();
                $model->$venderPhoneField = $venderPhone;
            }

            $mobileItem = $vender->getItem('mobile');
            if ($mobileItem instanceof BTreeItem) {
                $venderMobile = $mobileItem->getValue();
                $model->$venderMobileField = $venderMobile;
            }

            $emailItem = $vender->getItem('email');
            if ($emailItem instanceof BTreeItem) {
                $venderEmail = $emailItem->getValue();
                $model->$venderEmailField = $venderEmail;
            }

            $regionItem = $vender->getItem('region');
            if ($regionItem instanceof BTreeItem) {
                $venderRegion = $regionItem->getValue();
                $model->$venderRegionField = $venderRegion;
            }
        }
    }
}
?>
<?php
$app = Blyn::app()->getActiveApp();
?>
<legend><h4>
        <?php echo $control->getAjaxLink(array('name' => '活动列表', 'id' => 'showEventList')); ?>\
        <?php echo $control->getAjaxLink(array('name' => '配置列表', 'id' => 'showOrderConfigList'), array('eventId' => $eventId)); ?>\
        <?php echo '添加供应商信息'; ?>
    </h4></legend>
<table class="table table-hover">
    <colgroup>
        <col class="span1">
        <col class="span7">
    </colgroup>
    <thead>
        <tr>
            <th><?php echo '属性'; ?></th>
            <th><?php echo '内容'; ?></th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <?php echo '供应商ID'; ?>
            </td>
            <td>
                <div class="row">
                    <div class="span1"></div>
                    <div class="span2">ID:</div>
                    <div class="span6">
                        <?php
                        echo $form->textField($model, $venderIdField, array('placeholder' => '供应商ID' . '...', 'required' => true));
                        ?>
                    </div>
                </div>
                <div class="row">
                    <div class="span1"></div>
                    <div class="span2">Email:</div>
                    <div class="span6">
                        <?php
                        echo $form->textField($model, $venderIdField, array('placeholder' => '供应商ID' . '...', 'required' => true));
                        ?>
                    </div>
                </div>
                <!--                    &nbsp;&nbsp;&nbsp;&nbsp;<a id="CreateNewType_clink" role="button" data-toggle="modal" class="btn disabled" style="font-size: 12px;margin-top: -12px;">创建新类型</a>-->
            </td>
        </tr>
        <tr><td> <?php echo '名称'; ?> </td>
            <td>
                <?php
                echo $form->textField($model, $venderNameField, array('placeholder' => '名称' . '...', 'required' => true));
                ?>
            </td>
        </tr>               
        <tr>
            <td> <?php echo '简介'; ?>  </td>                    
            <td>
                <?php
                echo $form->textArea($model, $venderDescriptionField, array('placeholder' => '简介' . '...'));
                ?>
        </tr>
        <tr>
            <td> <?php echo '地区'; ?>  </td>                    
            <td>
                <?php
                echo $form->dropDownList($model, $venderRegionField, $app->getRegionList(), array('placeholder' => '简介' . '...'));
                ?>
        </tr>
        <tr>
            <td> <?php echo '地址'; ?>  </td>                    
            <td>
                <?php
                echo $form->textArea($model, $venderAddressField, array('placeholder' => '简介' . '...'));
                ?>
        </tr>
        <tr>
            <td> <?php echo '电话'; ?>  </td>                    
            <td>
                <?php
                echo $form->textArea($model, $venderPhoneField, array('placeholder' => '简介' . '...'));
                ?>
        </tr>
        <tr>
            <td> <?php echo '手机'; ?>  </td>                    
            <td>
                <?php
                echo $form->textArea($model, $venderMobileField, array('placeholder' => '简介' . '...'));
                ?>
        </tr>
    </tbody>
</table>